<?php
/**
 * Created by PhpStorm.
 * User: wanglong
 * Date: 2017/12/12
 * Time: 20:56
 */

namespace app\common\services;


//构建链接
use yii\helpers\Url;

class UrlServices
{
    //构建web端的URL
    public static function buildWebUrl($path,$params=[])
    {
        $path=Url::toRoute(array_merge([$path],$params));
        return "/web".$path;
    }

    //构建m端的URL
    public static function buildMUrl($path,$params=[])
    {
        $path=Url::toRoute(array_merge([$path],$params));
        return "/m".$path;
    }

    //构建默认的首页
    public static function buildWwwUrl($path,$params=[])
    {
        $path=Url::toRoute(array_merge([$path],$params));
        return $path;
    }

    //构建空链接
    public static function buildNullUrl()
    {

        return "javascript:void(0)";
    }

    public static function buildPicUrl($bucket,$image_key)
    {
        $domain_config=\Yii::$app->params['domain'];
        $upload_config=\Yii::$app->params['upload'];
        return $domain_config['www'].$upload_config[$bucket]."/".$image_key;
    }
}